<!DOCTYPE HTML>
<html>
<head th:replace="mgr/base/head :: head('统计')"></head>
<body>
	<nav th:replace="mgr/base/nav :: active('statistics')"></nav>
	<div id="page-wrapper" style="padding: 10px">
		<div class="container-fluid">
			<div class="row">
				<div class="col-md-8 ">
					<div class="alert alert-danger"
						th:text="${messages.getMessage(error)}" th:if="${error != null}"></div>
					<div class="form-group">
						<form th:action="@{/mgr/statistics}" method="get"
							id="statisticsForm">
							<select class="form-control" id="space" name="spaceId">
								<option value="">默认</option>
								<option th:value="${space.id}" th:each="space : ${spaces}"
									th:attr="selected=${(param.spaceId != null && param.spaceId[0] == (space.id+'')) ? 'selected' : null}"
									th:text="${space.name}"></option>
							</select>
						</form>
					</div>
					<div th:if="${statistics != null}">
						<div class="table-responsive"
							th:with="articleStatistics=${statistics.articleStatistics}">
							<table class="table">
								<caption>文章统计</caption>
								<tbody>
									<tr th:if="${articleStatistics.lastPubDate != null}">
										<th>最后发布日期</th>
										<td
											th:text="${times.format(articleStatistics.lastPubDate,'yyyy-MM-dd HH:mm')}"></td>
									</tr>
									<tr th:if="${articleStatistics.lastModifyDate != null}">
										<th>最后修改日期</th>
										<td
											th:text="${times.format(articleStatistics.lastModifyDate,'yyyy-MM-dd HH:mm')}"></td>
									</tr>
									<tr>
										<th>文章总数</th>
										<td th:text="${articleStatistics.totalArticles}"></td>
									</tr>
									<tr>
										<th>点击总数</th>
										<td th:text="${articleStatistics.totalHits}"></td>
									</tr>
									<tr
										th:each="statusCountMap : ${articleStatistics.statusCountMap}">
										<th
											th:text="${messages.getMessage(statusCountMap.key.message)}"></th>
										<td th:text="${statusCountMap.value}"></td>
									</tr>
								</tbody>
							</table>
						</div>
						
						<div class="table-responsive"
							th:with="newsStatistics=${statistics.newsStatistics}" th:if="${statistics.newsStatistics != null}">
							<table class="table">
								<caption>动态统计</caption>
								<tbody>
									<tr th:if="${newsStatistics.lastWrite != null}">
										<th>最后发布日期</th>
										<td
											th:text="${times.format(newsStatistics.lastWrite,'yyyy-MM-dd HH:mm')}" ></td>
									</tr>
									<tr th:if="${newsStatistics.lastModify != null}">
										<th>最后修改日期</th>
										<td
											th:text="${times.format(newsStatistics.lastModify,'yyyy-MM-dd HH:mm')}" ></td>
									</tr>
									<tr>
										<th>动态总数</th>
										<td th:text="${newsStatistics.total}"></td>
									</tr>
								</tbody>
							</table>
						</div>


						<div class="table-responsive"
							th:with="tagStatistics=${statistics.tagStatistics}">
							<table class="table">
								<caption>标签统计</caption>
								<tbody>
									<tr>
										<th>文章引用标签数</th>
										<td th:text="${tagStatistics.articleTagCount}"></td>
									</tr>
									<tr th:if="${tagStatistics.total != null}">
										<th>总标签数</th>
										<td th:text="${tagStatistics.total}"></td>
									</tr>
								</tbody>
							</table>
						</div>


						<div class="table-responsive"
							th:with="commentStatistics=${statistics.commentStatistics}">
							<table class="table">
								<caption>评论统计</caption>
								<tbody>
									<tr th:each="module : ${commentStatistics.modules}">
										<th th:text="${messages.getMessage(module.name)}"></th>
										<td th:text="${module.count}"></td>
									</tr>
								</tbody>
							</table>
						</div>

						<div class="table-responsive"
							th:with="pageStatistics=${statistics.pageStatistics}">
							<table class="table">
								<caption>页面统计</caption>
								<tbody>
									<tr>
										<th>自定义页面数</th>
										<td th:text="${pageStatistics.pageCount}"></td>
									</tr>
								</tbody>
							</table>
						</div>


						<div class="table-responsive"
							th:with="fileStatistics=${statistics.fileStatistics}"
							th:if="${statistics.fileStatistics != null}">
							<table class="table">
								<caption>文件统计</caption>
								<tbody>
									<tr th:each="typeCountMap : ${fileStatistics.typeCountMap}">
										<th
											th:text="${messages.getMessage(typeCountMap.key.message)}+'数'"></th>
										<td colspan="2" th:text="${typeCountMap.value}"></td>
									</tr>
									<object
										th:each="storeCountMap : ${fileStatistics.storeCountMap}"
										th:remove="tag">
										<tr>
											<th rowspan="2" th:text="${storeCountMap.key.name}"></th>
											<th>文件数</th>
											<td th:text="${storeCountMap.value.fileCount}"></td>
										</tr>
										<tr>
											<th>文件大小</th>
											<td th:text="${formats.readByte(storeCountMap.value.totalSize)}"></td>
										</tr>
									</object>
								</tbody>
							</table>
						</div>
						
						<div class="table-responsive"
							th:with="staticFileStatistics=${statistics.staticFileStatistics}" th:if="${statistics.staticFileStatistics != null}">
							<table class="table">
								<caption>本地文件统计</caption>
								<tbody>
									<tr>
										<th>文件夹数目</th>
										<td th:text="${staticFileStatistics.dirCount}"></td>
									</tr>
									<tr>
										<th>文件数目</th>
										<td th:text="${staticFileStatistics.fileCount}"></td>
									</tr>
									<tr>
										<th>文件总大小</th>
										<td th:text="${formats.readByte(staticFileStatistics.fileSize)}"></td>
									</tr>
								</tbody>
							</table>
						</div>
					</div>
				</div>
				<div class="col-md-4 ">
					<div class="alert alert-warning">
						<h4>关于文章统计：</h4>
						<p>无论文章处于何种状态(发布、计划、草稿，回收站)都将会被统计到，例如一篇处于回收站中的文章发布日期是最新的，那么最后发布日期将会取这篇文章的发布日期</p>

						<h4 style="margin-top: 20px">关于文章引用标签数统计：</h4>
						<p>无论文章处于何种状态(发布、计划、草稿，回收站)，只要该文章依旧持有对标签的引用，那么仍旧会统计该文章持有的标签，例如标签A被且仅被回收站中的文章A引用，那么统计文章引用标签数时依旧会统计到标签A</p>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div th:replace="base/foot_source"></div>
	<script type="text/javascript" th:src="@{/static/js/mgr/common.js}"></script>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#space").change(function() {
				$('#statisticsForm').submit();
			})
		});
	</script>
</body>
</html>
